package com.daigg.hoteladmin.controller;

import com.daigg.hoteladmin.pojo.po.BedTypePO;
import com.daigg.hoteladmin.pojo.vo.BedTypeVO;
import com.daigg.hoteladmin.service.IBedTypeService;
import com.daigg.hoteladmin.tools.Reply;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Description: 床的类型控制类
 * @author daiyang
 */
@Slf4j
@Api(tags="05.床的类型相关接口")
@RestController
@RequestMapping("api/bedType")
public class BedTypeController {
    @Autowired
    IBedTypeService bedTypeService;

    @PostMapping("/add")
    @ApiOperation("添加床的类型")
    public Reply<BedTypeVO> add(@RequestBody BedTypeVO bedTypeVO ){
        return Reply.success(bedTypeService.add(bedTypeVO));
    }

    @GetMapping("/delete/{id}")
    @ApiOperation("删除床的类型")
    public Reply deleteById(@PathVariable("id") String id){
        return bedTypeService.deleteById(id)>0? Reply.success() :Reply.failed();
    }

    @ApiOperation("根据id查找床的类型")
    @GetMapping("/get/{id}")
    public Reply<BedTypeVO> selectById(@PathVariable("id")String id){
        return Reply.success(bedTypeService.selectOneByIdReturnVO(id));
    }

    @ApiOperation("更改床的类型")
    @PostMapping("modify")
    public Reply<BedTypeVO> modify(@RequestBody BedTypeVO bedTypeVO){
        return Reply.success(bedTypeService.saveone(bedTypeVO));
    }

    // @ApiOperation("获取床的类型(分页)")
    // @PostMapping("page")
    // public Reply<Page<BedTypeVO>> getPage(@RequestBody BedTypeVO bedTypeVO){
    //     return (Reply<Page<BedTypeVO>>) Reply.success(bedTypeService.getPage(bedTypeVO));
    // }

    @ApiOperation("获取床的类型")
    @GetMapping("/list")
    public Reply<List<BedTypePO>> getList(){
        log.debug("开始处理【获取床的类型】请求");
        return Reply.success(bedTypeService.getList());
    }

}
